<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .img{
            list-style: none;
            width: 590px;
            height: 470px;
            position:absolute;
            transition: 0.6s;
            opacity: 0;

        }
        .img-box{
            margin: 0px;
            padding: 0px;
            width: 590px;
            height: 470px;
            position: relative;
        }
        button {
            position:absolute;
            height: 50px;
            width:50px;
            background-color:rgba(0, 0, 0, 0.5);
            color: azure;
            top: 50%;
            transform: translateY(-50%);
            border: none;
            z-index: 100;
            /* opacity:0.5; */
        }
        .left {
            border-radius: 0px 20px 20px 0px;
        }
        .right {
            border-radius: 20px 0px 0px 20px;
            right: 0px;
        }
        .point-box {
            position: absolute;
            list-style: none;
            padding: 0px;
            margin: 0px;
            display: flex;
            width: 100px;
            justify-content: space-between;
            bottom: 20px;
            left: 20px;
        }
        .point {
            height: 10px;
            width: 10px;
            border-radius: 50%;
            background-color: black;
            color: rgba(0, 0, 0, 0);
        }
        .active {
            /* z-index: 10; */
            opacity: 1;
        }
        .pointActive{
            background-color: white;
        }
        

    </style>
</head>
<body>
<ul class="img-box">
    <li class="img active"><img src="./1.jpg" alt=""></li>
    <li class="img"><img src="./2.jpg" alt=""></li>
    <li class="img"><img src="./3.jpg" alt=""></li>
    <li class="img"><img src="./4.jpg" alt=""></li>
    <li class="img"><img src="./5.jpg" alt=""></li>
    <li class="img"><img src="./6.jpg" alt=""></li>
    <button class="left"><</button>
    <button class="right">></button>
    <ul class="point-box">
        <li class="point"></li>
        <li class="point"></li>
        <li class="point"></li>
        <li class="point"></li>
        <li class="point"></li>
        <li class="point"></li>
    </ul>
</ul> 
<script>
    let left=document.querySelector('.left')
    let right=document.querySelector('.right')
    let imgs=document.querySelectorAll('.img')
    let index=0
    let points = document.querySelectorAll('.point') 
    right.addEventListener('click',function(){
        imgs[index].classList.remove('active')
        points[index].classList.remove('pointActive')
            index++;
            if (index >= 6) {
                index = 0
            }
            imgs[index].classList.add('active')
            points[index].classList.add('pointActive')

    })
    left.addEventListener('click', function () {
            imgs[index].classList.remove('active')
            points[index].classList.remove('pointActive')
            index--;
            if (index <= -1) {
                index = 5
            }
            imgs[index].classList.add('active')
            points[index].classList.add('pointActive')
        })
 
        points.forEach(function (item) {
            item.addEventListener('mousemove', function () {
                imgs[index].classList.remove('active')
                points[index].classList.remove('pointActive')
                index = this.innerText - 1
                imgs[index].classList.add('active')
                points[index].classList.add('pointActive')
            })
        })
 
        setInterval(function () {
            imgs[index].classList.remove('active')
            points[index].classList.remove('pointActive')
            index++;
            if (index >= 6) {
                index = 0
            }
            imgs[index].classList.add('active')
            points[index].classList.add('pointActive')
        }, 2000);


</script>   
</body>
</html>